package br.com.siscov.control.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

import br.com.siscov.util.Constantes;

public class LogoffAction extends Action {

	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
		ActionErrors errors = new ActionErrors();
			try {

			//LogarForm loginForm = (LogarForm) form;
			//loginForm.setLogin("");
			//loginForm.setSenha("");
			
			//LoginVo loginVo = loginForm.populaVO();
			request.getSession().getAttribute(Constantes.SESSAO_LOGIN);

			request.getSession().invalidate();
			
			return mapping.findForward(Constantes.FORWARD_SUCESSO);
			
						
		} catch (Exception e) {
			errors.add("errors", new ActionMessage("errors.login.invalido.exception"));
			saveErrors(request, errors);
			return mapping.findForward(Constantes.FWD_ERRO);
		}
	}


}
